package net.ojbk.study.curriculumDesign.service.cilentservicer.impl;

import net.ojbk.study.curriculumDesign.beans.cilentservicer.Chat;
import net.ojbk.study.curriculumDesign.beans.cilentservicer.Servicer;
import net.ojbk.study.curriculumDesign.service.cilentservicer.IServicerManaService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/1/9
 * Time: 12:28
 * Description: No Description
 */
@Service("servicerManaService")
public class ServicerManaServiceImpl implements IServicerManaService {
    /**
     * 该客服是否还有新消息。
     *
     * @param servicer 客服
     * @return
     */
    @Override
    public boolean isHaveNewMsg(Servicer servicer) throws Exception{
        if (servicer == null)
            throw new Exception("错误客服");
        List<Chat> chatList = servicer.getsChatList();
        for (Chat chat : chatList) {
            if (!chat.getSuserNewMsgList().isEmpty())
                return true;
        }
        return false;
    }

    /**
     * 设置客服的状态
     *
     * @param servicer  这个客服
     * @param newStatus 新的状态，请使用客服状态接口定义号的变量
     */
    @Override
    public void setMeStatus(Servicer servicer, int newStatus) {
        servicer.setStatus(newStatus);
    }

    /**
     * 获取此客服的评分
     *
     * @param servicer 这个客服，哈哈哈
     * @return 分数
     */
    @Override
    public double getMeScore(Servicer servicer) {
        return servicer.getDivScore();
    }
}
